#pragma once

#include <AVUIPathSegment.h>

namespace AVUI {

class GeometryBuilder;
class Point;

class BezierSegment : public PathSegment
{
public:
    DECLARE_ELEMENT(BezierSegment, PathSegment);

    DECLARE_DEPENDENCY_PROPERTY(Point1);
    Point get_Point1() { return AVUI::UnboxValue<Point>(GetValue(get_Point1Property())); }
    void set_Point1(const Point& value) { SetValue(get_Point1Property(), AVUI::BoxValue(value)); } 

    DECLARE_DEPENDENCY_PROPERTY(Point2);
    Point get_Point2() { return AVUI::UnboxValue<Point>(GetValue(get_Point2Property())); }
    void set_Point2(const Point& value) { SetValue(get_Point2Property(), AVUI::BoxValue(value)); } 

    DECLARE_DEPENDENCY_PROPERTY(Point3);
    Point get_Point3() { return AVUI::UnboxValue<Point>(GetValue(get_Point3Property())); }
    void set_Point3(const Point& value) { SetValue(get_Point3Property(), AVUI::BoxValue(value)); } 

    virtual bool IsCurved() { return true; }
    virtual Rect GetBounds(Point* pStartPoint);
    virtual int ClassifyPoint(const Point& pointClassify, Point* pStartPoint);

    static void StaticBuildGeometry(GeometryBuilder* pGB, const Point& startPoint, const Point& point1, const Point& point2, const Point& point3);
    static void StaticBuildGeometryRecursive(GeometryBuilder* pGB, const Point& p1, const Point& p2, const Point& p3, const Point& p4, int level, float distToleranceSquare, float distToleranceAroundSquare);

protected:

    virtual TRefCountedPtr<Freezable> CreateInstanceCore() AVUI_OVERRIDE { return object_allocate<BezierSegment>().get_Ptr(); }

private:
    static void StaticConstructor();

    virtual Point BuildGeometry(GeometryBuilder* pGB, const Point& startPoint);

};



}; // namespace AVUI
